home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 712 / code.txt next >
Encoding:
Text File  |  1993-05-27  |  5.4 KB  |  136 lines

  1. Path: news1.cis.umn.edu!umn.edu!news-feed-1.peachnet.edu!gatech!howland.reston.ans.net!ux1.cso.uiuc.edu!uwm.edu!caen!batcomputer!munnari.oz.au!bunyip.cc.uq.oz.au!uqcspe!cs.uq.oz.au!warwick
  2. From: warwick@cs.uq.oz.au (Warwick Allison)
  3. Newsgroups: comp.sys.atari.st
  4. Subject: Re: Cross compiling with GNU C for ST?
  5. Message-ID: <13501@uqcspe.cs.uq.oz.au>
  6. Date: 21 May 93 01:17:01 GMT
  7. References: <1t9akh$9b9@eckserver.eckerd.edu> <13460@uqcspe.cs.uq.oz.au> <C7Ap6t.FDM@well.sf.ca.us>
  8. Sender: news@cs.uq.oz.au
  9. Reply-To: warwick@cs.uq.oz.au
  10. Lines: 124
  11.  
  12. comeau@csanta.attmail.com (Greg Comeau) writes:
  13.  
  14. >warwick@cs.uq.oz.au writes:
  15. >>You could just use my GEM++ C++ class library (written in GNU C++ of course).
  16.  
  17. >I'd be interested in hearing more about this, and AMS.
  18.  
  19. Greg may have intended to email, but I think this is worth posting anyway.
  20.  
  21.  
  22. I am a strong believer in sharing code.  And I think C++ is THE language for
  23. doing it.  The reasons are:
  24.  
  25.     1. It is as popular as C (or at least, it shortly will be).
  26.         - You need a userbase in order to share code
  27.     2. It has a high level of information hiding - encapulation.
  28.         - You need this, or else chaos eats you up.
  29.  
  30. Now, it seems to me that there are three types of applications written for the
  31. Atari computers:
  32.  
  33.     1. Machine independent (eg. all the ported GNU tools)
  34.     2. GEM dependent (all those nice apps that run on all screen sizes)
  35.     3. Machine specific (they run in only one or two fixed resolutions)
  36.  
  37. For (1), you can use all the world's class libraries.
  38.  
  39. For (2), I wrote GEM++.
  40. For (3), I wrote AMS.
  41.  
  42. >Any chance of giving a "mild" example, maybe a screens-worth [of GEM++]?
  43.  
  44. Here is some example code I just made up:
  45.  
  46. -----------------------------------------------------------------------------
  47.  
  48.     main()
  49.     {
  50.         // Before we do ANYTHING with GEM, we must declare a GEMapplication.
  51.         // This does the old appl_init/appl_exit stuff for us.
  52.         GEMapplication example;
  53.  
  54.         // Create some GEMrsc objects (they load RSC files)...
  55.         GEMrsc rsc1("example.rsc",8,16);
  56.         GEMrsc rsc2("exam2.rsc",8,16);
  57.  
  58.         // Create some GEMform objects from those GEMrsc objects
  59.         // by simply using the RSC indices that we used in the
  60.         // RSC editor.
  61.         GEMform form1(rsc1,FORM1_RSC_INDEX);
  62.         GEMform form2(rsc2,SOME_OTHER_INDEX);
  63.  
  64.         // We can make a complete COPY of a form very easily...
  65.         // This copies all the user-modifiable parts of the form,
  66.         // but can just share the original copies of constant things
  67.         // like titles strings, etc.
  68.         GEMform anotherform=form1;
  69.  
  70.         // To use forms, we just "Do" them...   [ SEE NOTE 1 ]
  71.         form1.Do();         // (centred)
  72.         form1.Do(100,30);   // (at a given position)
  73.  
  74.         // If we declare GEMobject objects :) in the GEMform, we
  75.     // can find out more via those GEMobjects.  Again, we simply
  76.         // use the RSC indices to refer to objects...
  77.         GEMobject the_okay_button(form1,OKAY_BUTTON);
  78.  
  79.         if (the_okay_button.Selected()) {
  80.             printf("OKAY selected\n");
  81.         }
  82.  
  83.         // More interesting than GEMforms, are GEMformwindows, which
  84.         // are just like GEM forms, except they are in a window.
  85.         //
  86.         // To use GEMformwindows, we need a GEMactivity in which the
  87.         // windows act.  This encapsulates all the event handling
  88.         // code, and all those ugly low-level things that C GEM users
  89.         // had to deal with.
  90.         GEMactivity activity;
  91.  
  92.         // Then, all we do to have a window is say which GEMactivity
  93.         // it is in, and get the graphics out of a GEMrsc.
  94.         GEMformwindow my_window(activity,rsc1,MY_WINDOW_INDEX);
  95.  
  96.         // Open the window...  [ SEE NOTE 2 ]
  97.         my_window.Open();
  98.  
  99.         // And set it all in motion...  [ SEE NOTE 3 ]
  100.         activity.Do();
  101.     }
  102.  
  103. NOTES:
  104.     1. Normally, the user will create a derived class of GEMform
  105.         that encapsulates the actions that need to happen when
  106.         the user interacts with a form.  This is done by overriding
  107.         the virtual method "DoItem(int item, const GEMevent& e)",
  108.         or by declaring actuve GEMobjects in the form.  But here,
  109.         for simplicity, I have shown GEMforms being used directly.
  110.     2. Cleverly, GEM++ only calls the GEM "wind_create" funtion
  111.         when a window is actually opened.  This way, you can have
  112.         any number of "GEMwindows" (of which GEMformwindow is one type)
  113.         and only the OPEN ones will take up GEM window handles.
  114.         (which are limited in some TOS versions)
  115.     3. Normally, the user will have other things like a GEMmenu
  116.         object, maybe a GEMdesktop [though not advisable under
  117.         MultiTOS!], other windows, etc. in the activity.
  118.  
  119. -----------------------------------------------------------------------------
  120.  
  121. >Do you use any of the g++ extensions/incompatibilities?
  122. >I ask this as I'd imagine that if it didn't, that it would
  123. >probably mesh with Comeau C++ 3.0 With Templates reasonably.
  124.  
  125. I have tried to avoid any dependence on GNU C++, but only having one
  126. compiler to check against, I guess some minor dependencies may exist
  127. (ie. bugs in my code that G++ lets slide).
  128.  
  129.  
  130. --
  131. Warwick
  132.   _-_|\      warwick@cs.uq.oz.au            ||||||  AMS  = C++ game library   |
  133.  /     * <-- Computer Science Department,   |||||| GEM++ = C++ GEM library    |
  134.  \_.-._/     University of Queensland,    _// || \\_   Both are GNUish = Free |
  135. _____ v ____ Brisbane, Australia. ______ |_/  ||  \_| ________________________|
  136.